package com.lcz.fruitweb.dao;

import model.Fruit;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 对水果进行操作---业务层发的通知
 *
 * @author 才智
 */
public interface FruitDao {
    /**
     * @param fruit
     * @return
     */
    @Insert("insert into db_fruit values(default ,#{name},#{number},#{price},#{remark})")
    boolean save(Fruit fruit);

    @Delete("delete from db_fruit where id=#{id}")
    void del(int id);

    /**
     * @param id
     * @return
     */
    @Select("select * from db_fruit where id=#{id}")
    Fruit findById(int id);

    /**
     * @param fruit
     * @return
     */
    @Update("update db_fruit set name=#{name},price=#{price},number=#{number},remark=#{remark} where id=#{id}")
    boolean update(Fruit fruit);

    /**
     * @return
     */
    @Select("select * from db_fruit")
    List<Fruit> findAll();
}
